一切步骤按照https://lijiancheng0614.github.io/2017/06/29/2017_06_29_TensorFlow-Slim-image-classification/#%E9%AA%8C%E8%AF%81 这篇博客来的。
其中遇到的问题:
InvalidArgumentError (see above for traceback): Cannot assign a device for operation 'gradients/aux_loss/xentropy_grad/LogSoftmax': Could not satisfy explicit device specification '/device:GPU:0' because no supported kernel for GPU devices is available.
Registered kernels:device='CPU'; T in [DT_HALF]
device='CPU'; T in [DT_FLOAT]
device='CPU'; T in [DT_DOUBLE]
[[Node: gradients/aux_loss/xentropy_grad/LogSoftmax = LogSoftmax[T=DT_FLOAT, _device="/device:GPU:0"](aux_loss/xentropy/Reshape)]]
解决办法:
在train_image_classifier中加入一句:
config = tf.ConfigProto(allow_soft_placement = True)
然后在最后的定义中:
slim.learning.train(
train_tensor,
......
session_config = config
)
加粗的这句话即可